<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>The AnnotationSketch module</title>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<div id="menu">
<ul>
<li><a href="index.html">Overview</a></li>
<li><a href="https://github.com/genometools/genometools/releases">Releases</a></li>
<li><a href="pub/">Archive</a></li>
<li><a href="https://github.com/genometools/genometools">Browse source</a></li>
<li><a href="http://github.com/genometools/genometools/issues/">Issue tracker</a></li>
<li><a href="documentation.html">Documentation</a></li>
<li><a href="annotationsketch.html"><tt>AnnotationSketch</tt></a></li>
  <ul class="submenu">
    <li><a href="annotationsketch.html#collapsing">Collapsing</a></li>
    <li><a href="annotationsketch.html#styles">Styles</a></li>
    <li><a href="trackselectors.html">Track assignment</a></li>
    <li><a href="customtracks.html">Custom tracks</a></li>
    <li><a href="annotationsketch.html#gtsketch">The <tt>gt sketch</tt> tool</a></li>
    <li><a id="current" href="examples.html">Code examples</a></li>
    <li><a href="libgenometools.html">API reference</a></li>
  </ul>
<li><a href="/cgi-bin/gff3validator.cgi">GFF3 validator</a></li>
<li><a href="license.html">License</a></li>
</ul>
</div>


<div id="main">
<h1><em>AnnotationSketch</em> code examples</h1>

<a name="examples-parsed"></a>
<h2>Using <em>AnnotationSketch</em> to draw annotations from a file</h2>
The following code examples (in C and Lua) illustrate how to produce an image from a given GFF3 file using <em>AnnotationSketch</em>. The result is shown in Fig. <a href="#fig7">7</a>. In essence, these code examples implement something like a simple version of the <tt>gt sketch</tt> tool from <em>GenomeTools</em> without most command-line options.
<div class="figure">
  <p><a name="fig7"></a><img src="images/parsed.png" alt="[Example rendering from parsed GFF3 file]"></p>
  <p><b>Figure 7: </b>Example rendering of a GFF3 file with default style.</p>
</div>

<h4>C code</h4>
(See <a href="https://github.com/genometools/genometools/blob/master/src/examples/sketch_parsed.c"><tt>src/examples/sketch_parsed.c</tt></a> in the source distribution.)
<pre class="code">
<!--#include file="src/examples/sketch_parsed.c"-->
</pre>

<h4>Lua code</h4>
(See <a href="https://github.com/genometools/genometools/blob/master/gtscripts/sketch_parsed.lua"><tt>gtscripts/sketch_parsed.lua</tt></a> in the source distribution. This example can be run by the command line <tt>gt gtscripts/sketch_parsed.lua &lt;style_file&gt; &lt;PNG_file&gt; &lt;GFF3_file&gt;</tt>)
<pre class="code">
<!--#include file="gtscripts/sketch_parsed.lua"-->
</pre>

<h4>Ruby code</h4>
(See <a href="https://github.com/genometools/genometools/blob/master/gtruby/sketch_parsed.rb"><tt>gtruby/sketch_parsed.rb</tt></a> in the source distribution.)
<pre class="code">
<!--#include file="gtruby/sketch_parsed.rb"-->
</pre>

<h4>Python code</h4>
(See <a href="https://github.com/genometools/genometools/blob/master/gtpython/sketch_parsed.py"><tt>gtpython/sketch_parsed.py</tt></a> in the source distribution.)
<pre class="code">
<!--#include file="gtpython/sketch_parsed.py"-->
</pre>


<a name="examples-generated"></a>
<h2>Using <em>AnnotationSketch</em> to draw user-generated annotations</h2>
The following C code example illustrates how to produce an image from annotation graphs created by user code.
 The result is shown in Fig. <a href="#fig8">8</a>.
<div class="figure">
  <p><a name="fig8"></a><img src="images/constructed.png" alt="[Example rendering from user-generated annotations]"></p>
  <p><b>Figure 8: </b>Example rendering of user-generated annotations with default style.</p>
</div>

<h4>C code</h4>
(See <a href="https://github.com/genometools/genometools/blob/master/src/examples/sketch_constructed.c"><tt>src/examples/sketch_constructed.c</tt></a> in the source distribution.)
<pre class="code">
<!--#include file="src/examples/sketch_constructed.c"-->
</pre>

<h4>Lua code</h4>
(See <a href="https://github.com/genometools/genometools/blob/master/gtscripts/sketch_constructed.lua"><tt>gtscripts/sketch_constructed.lua</tt></a> in the source distribution.  This example can be run by the command line <tt>gt gtscripts/sketch_constructed.lua &lt;style_file&gt; &lt;PNG_file&gt;</tt>)
<pre class="code">
<!--#include file="gtscripts/sketch_constructed.lua"-->
</pre>

<h4>Ruby code</h4>
(See <a href="https://github.com/genometools/genometools/blob/master/gtruby/sketch_constructed.rb"><tt>gtruby/sketch_constructed.rb</tt></a> in the source distribution.)
<pre class="code">
<!--#include file="gtruby/sketch_constructed.rb"-->
</pre>

<h4>Python code</h4>
(See <a href="https://github.com/genometools/genometools/blob/master/gtpython/sketch_constructed.py"><tt>gtpython/sketch_constructed.py</tt></a> in the source distribution.)
<pre class="code">
<!--#include file="gtpython/sketch_constructed.py"-->
</pre>

<div id="footer">
Copyright &copy; 2007-2023 The <i>GenomeTools</i> authors. Last update: 2011-02-11
</div>
</div>
</body>
</html>
